        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>Fixture class / box2d_console Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d_console" data-type="Fixture">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d_console.html">box2d_console</a> &rsaquo; <a href="../box2d_console/Fixture.html">Fixture</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>Fixture</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>A fixture is used to attach a shape to a body for collision detection.
You cannot reuse fixtures.</p>
<pre class="source">
class Fixture {
  final AxisAlignedBox box;

  num density;

  Fixture next;

  Body body;

  Shape shape;

  num friction;

  num restitution;

  DynamicTreeNode proxy;

  final Filter filter;

  bool isSensor;

  Object userData;

  final AxisAlignedBox _poolOne;
  final AxisAlignedBox _poolTwo;

  /**
   * Constructs a new Fixture with default values.
   */
  Fixture()
      : box = new AxisAlignedBox(),
        body = null,
        next = null,
        proxy = null,
        shape = null,
        filter = new Filter(),
        _poolOne = new AxisAlignedBox(),
        _poolTwo = new AxisAlignedBox();

  /**
   * Sets this fixture according to the given body and definition.
   */
  void create(Body b, FixtureDef def) {
    userData = def.userData;
    friction = def.friction;
    restitution = def.restitution;

    body = b;
    next = null;

    filter.setFrom(def.filter);

    isSensor = def.isSensor;

    shape = def.shape.clone();

    density = def.density;
  }

  /**
   * Destroys this fixture. Before being called, this shape's proxy must be
   * destroyed. After being called, this fixture's shape is null.
   */
  void destroy() {
    // The proxy must be destroyed before calling this.
    assert(proxy == null);

    // Free the child shape.
    shape = null;
  }

  /** These support body activation/deactivation. */
  void createProxy(BroadPhase broadPhase, Transform xf){
    assert(proxy == null);

    // Create proxy in the broad-phase.
    shape.computeAxisAlignedBox(box, xf);
    proxy = broadPhase.createProxy(box, this);
  }

  /**
   * Destroys this Fixture's proxy.
   */
  void destroyProxy(BroadPhase broadPhase) {
    // If proxy is already destroyed, do nothing.
    if (proxy == null) {
      return;
    }

    // Destroy the proxy.
    broadPhase.destroyProxy(proxy);
    proxy = null;
  }

  //TODO(gregbglw): Write comment once know what does.
  void synchronize(BroadPhase broadPhase, Transform transformOne,
      Transform transformTwo) {
    if (proxy == null) {
      return;
    }

    // Compute an Axis Aligned Box that covers the swept shape.
    shape.computeAxisAlignedBox(_poolOne, transformOne);
    shape.computeAxisAlignedBox(_poolTwo, transformTwo);
    box.lowerBound.x = _poolOne.lowerBound.x &lt; _poolTwo.lowerBound.x ? 
        _poolOne.lowerBound.x : _poolTwo.lowerBound.x;
    box.lowerBound.y = _poolOne.lowerBound.y &lt; _poolTwo.lowerBound.y ?
        _poolOne.lowerBound.y : _poolTwo.lowerBound.y;
    box.upperBound.x = _poolOne.upperBound.x &gt; _poolTwo.upperBound.x ?
        _poolOne.upperBound.x : _poolTwo.upperBound.x;
    box.upperBound.y = _poolOne.upperBound.y &gt; _poolTwo.upperBound.y ?
        _poolOne.upperBound.y : _poolTwo.upperBound.y;

    Vector disp = _poolOne.lowerBound;
    disp.x = transformTwo.position.x - transformOne.position.x;
    disp.y = transformTwo.position.y - transformOne.position.y;

    broadPhase.moveProxy(proxy, box, disp);
  }

  /**
   * Get the mass data for this fixture. The mass data is based on the density
   * and the shape. The rotational inertia is about the shape's origin.
   */
  void getMassData(MassData massData) {
    shape.computeMass(massData, density);
  }

  /**
   * Get the type of the child shape.
   */
  int get type() {
    return shape.type;
  }
}
</pre>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="Fixture">
<button class="show-code">Code</button>
new <strong>Fixture</strong>() <a class="anchor-link" href="#Fixture"
              title="Permalink to Fixture.Fixture">#</a></h4>
<div class="doc">
<p>Constructs a new Fixture with default values.</p>
<pre class="source">
Fixture()
    : box = new AxisAlignedBox(),
      body = null,
      next = null,
      proxy = null,
      shape = null,
      filter = new Filter(),
      _poolOne = new AxisAlignedBox(),
      _poolTwo = new AxisAlignedBox();
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="body">
<button class="show-code">Code</button>
<a href="../box2d_console/Body.html">Body</a>         <strong>body</strong> <a class="anchor-link"
            href="#body"
            title="Permalink to Fixture.body">#</a>
        </h4>
        <div class="doc">
<pre class="source">
Body body;
</pre>
</div>
</div>
<div class="field"><h4 id="box">
<button class="show-code">Code</button>
final <a href="../box2d_console/AxisAlignedBox.html">AxisAlignedBox</a>         <strong>box</strong> <a class="anchor-link"
            href="#box"
            title="Permalink to Fixture.box">#</a>
        </h4>
        <div class="doc">
<pre class="source">
final AxisAlignedBox box;
</pre>
</div>
</div>
<div class="field"><h4 id="density">
<button class="show-code">Code</button>
num         <strong>density</strong> <a class="anchor-link"
            href="#density"
            title="Permalink to Fixture.density">#</a>
        </h4>
        <div class="doc">
<pre class="source">
num density;
</pre>
</div>
</div>
<div class="field"><h4 id="filter">
<button class="show-code">Code</button>
final <a href="../box2d_console/Filter.html">Filter</a>         <strong>filter</strong> <a class="anchor-link"
            href="#filter"
            title="Permalink to Fixture.filter">#</a>
        </h4>
        <div class="doc">
<pre class="source">
final Filter filter;
</pre>
</div>
</div>
<div class="field"><h4 id="friction">
<button class="show-code">Code</button>
num         <strong>friction</strong> <a class="anchor-link"
            href="#friction"
            title="Permalink to Fixture.friction">#</a>
        </h4>
        <div class="doc">
<pre class="source">
num friction;
</pre>
</div>
</div>
<div class="field"><h4 id="isSensor">
<button class="show-code">Code</button>
bool         <strong>isSensor</strong> <a class="anchor-link"
            href="#isSensor"
            title="Permalink to Fixture.isSensor">#</a>
        </h4>
        <div class="doc">
<pre class="source">
bool isSensor;
</pre>
</div>
</div>
<div class="field"><h4 id="next">
<button class="show-code">Code</button>
<a href="../box2d_console/Fixture.html">Fixture</a>         <strong>next</strong> <a class="anchor-link"
            href="#next"
            title="Permalink to Fixture.next">#</a>
        </h4>
        <div class="doc">
<pre class="source">
Fixture next;
</pre>
</div>
</div>
<div class="field"><h4 id="proxy">
<button class="show-code">Code</button>
<a href="../box2d_console/DynamicTreeNode.html">DynamicTreeNode</a>         <strong>proxy</strong> <a class="anchor-link"
            href="#proxy"
            title="Permalink to Fixture.proxy">#</a>
        </h4>
        <div class="doc">
<pre class="source">
DynamicTreeNode proxy;
</pre>
</div>
</div>
<div class="field"><h4 id="restitution">
<button class="show-code">Code</button>
num         <strong>restitution</strong> <a class="anchor-link"
            href="#restitution"
            title="Permalink to Fixture.restitution">#</a>
        </h4>
        <div class="doc">
<pre class="source">
num restitution;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="runtimeType">
<button class="show-code">Code</button>
final Type         <strong>runtimeType</strong> <a class="anchor-link"
            href="#runtimeType"
            title="Permalink to Fixture.runtimeType">#</a>
        </h4>
        <div class="inherited-from">inherited from Object </div><div class="doc">
<p>A representation of the runtime type of the object.</p>
<pre class="source">
external Type get runtimeType;
</pre>
</div>
</div>
<div class="field"><h4 id="shape">
<button class="show-code">Code</button>
<a href="../box2d_console/Shape.html">Shape</a>         <strong>shape</strong> <a class="anchor-link"
            href="#shape"
            title="Permalink to Fixture.shape">#</a>
        </h4>
        <div class="doc">
<pre class="source">
Shape shape;
</pre>
</div>
</div>
<div class="field"><h4 id="type">
<button class="show-code">Code</button>
final int         <strong>type</strong> <a class="anchor-link"
            href="#type"
            title="Permalink to Fixture.type">#</a>
        </h4>
        <div class="doc">
<p>Get the type of the child shape.</p>
<pre class="source">
int get type() {
  return shape.type;
}
</pre>
</div>
</div>
<div class="field"><h4 id="userData">
<button class="show-code">Code</button>
Object         <strong>userData</strong> <a class="anchor-link"
            href="#userData"
            title="Permalink to Fixture.userData">#</a>
        </h4>
        <div class="doc">
<pre class="source">
Object userData;
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method inherited"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to Fixture.operator ==">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>The equality operator.</p>
<p>The default behavior for all <code>Object</code>s is to return true if and
only if <code>this</code> and 
<span class="param">other</span> are the same object.</p>
<p>If a subclass overrides the equality operator it should override
the <code>hashCode</code> method as well to maintain consistency.</p>
<pre class="source">
bool operator ==(other) =&gt; identical(this, other);
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="create">
<button class="show-code">Code</button>
void <strong>create</strong>(<a href="../box2d_console/Body.html">Body</a> b, <a href="../box2d_console/FixtureDef.html">FixtureDef</a> def) <a class="anchor-link" href="#create"
              title="Permalink to Fixture.create">#</a></h4>
<div class="doc">
<p>Sets this fixture according to the given body and definition.</p>
<pre class="source">
void create(Body b, FixtureDef def) {
  userData = def.userData;
  friction = def.friction;
  restitution = def.restitution;

  body = b;
  next = null;

  filter.setFrom(def.filter);

  isSensor = def.isSensor;

  shape = def.shape.clone();

  density = def.density;
}
</pre>
</div>
</div>
<div class="method"><h4 id="createProxy">
<button class="show-code">Code</button>
void <strong>createProxy</strong>(<a href="../box2d_console/BroadPhase.html">BroadPhase</a> broadPhase, <a href="../box2d_console/Transform.html">Transform</a> xf) <a class="anchor-link" href="#createProxy"
              title="Permalink to Fixture.createProxy">#</a></h4>
<div class="doc">
<p>These support body activation/deactivation.</p>
<pre class="source">
void createProxy(BroadPhase broadPhase, Transform xf){
  assert(proxy == null);

  // Create proxy in the broad-phase.
  shape.computeAxisAlignedBox(box, xf);
  proxy = broadPhase.createProxy(box, this);
}
</pre>
</div>
</div>
<div class="method"><h4 id="destroy">
<button class="show-code">Code</button>
void <strong>destroy</strong>() <a class="anchor-link" href="#destroy"
              title="Permalink to Fixture.destroy">#</a></h4>
<div class="doc">
<p>Destroys this fixture. Before being called, this shape's proxy must be
destroyed. After being called, this fixture's shape is null.</p>
<pre class="source">
void destroy() {
  // The proxy must be destroyed before calling this.
  assert(proxy == null);

  // Free the child shape.
  shape = null;
}
</pre>
</div>
</div>
<div class="method"><h4 id="destroyProxy">
<button class="show-code">Code</button>
void <strong>destroyProxy</strong>(<a href="../box2d_console/BroadPhase.html">BroadPhase</a> broadPhase) <a class="anchor-link" href="#destroyProxy"
              title="Permalink to Fixture.destroyProxy">#</a></h4>
<div class="doc">
<p>Destroys this Fixture's proxy.</p>
<pre class="source">
void destroyProxy(BroadPhase broadPhase) {
  // If proxy is already destroyed, do nothing.
  if (proxy == null) {
    return;
  }

  // Destroy the proxy.
  broadPhase.destroyProxy(proxy);
  proxy = null;
}
</pre>
</div>
</div>
<div class="method"><h4 id="Fixture">
<button class="show-code">Code</button>
new <strong>Fixture</strong>() <a class="anchor-link" href="#Fixture"
              title="Permalink to Fixture.Fixture">#</a></h4>
<div class="doc">
<p>Constructs a new Fixture with default values.</p>
<pre class="source">
Fixture()
    : box = new AxisAlignedBox(),
      body = null,
      next = null,
      proxy = null,
      shape = null,
      filter = new Filter(),
      _poolOne = new AxisAlignedBox(),
      _poolTwo = new AxisAlignedBox();
</pre>
</div>
</div>
<div class="method"><h4 id="getMassData">
<button class="show-code">Code</button>
void <strong>getMassData</strong>(<a href="../box2d_console/MassData.html">MassData</a> massData) <a class="anchor-link" href="#getMassData"
              title="Permalink to Fixture.getMassData">#</a></h4>
<div class="doc">
<p>Get the mass data for this fixture. The mass data is based on the density
and the shape. The rotational inertia is about the shape's origin.</p>
<pre class="source">
void getMassData(MassData massData) {
  shape.computeMass(massData, density);
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="hashCode">
<button class="show-code">Code</button>
int <strong>hashCode</strong>() <a class="anchor-link" href="#hashCode"
              title="Permalink to Fixture.hashCode">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Get a hash code for this object.</p>
<p>All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator <code>==</code>. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.</p>
<p>If a subclass overrides <code>hashCode</code> it should override the
equality operator as well to maintain consistency.</p>
<pre class="source">
external int hashCode();
</pre>
</div>
</div>
<div class="method inherited"><h4 id="noSuchMethod">
<button class="show-code">Code</button>
<strong>noSuchMethod</strong>(String name, List args) <a class="anchor-link" href="#noSuchMethod"
              title="Permalink to Fixture.noSuchMethod">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p><code>noSuchMethod</code> is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to <code>noSuchMethod</code>. If <code>noSuchMethod</code>
returns a value, that value becomes the result of the original
invocation.</p>
<p>The default behavior of <code>noSuchMethod</code> is to throw a
<code>noSuchMethodError</code>.</p>
<pre class="source">
external Dynamic noSuchMethod(String name, List args);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Object">
<button class="show-code">Code</button>
const <strong>Object</strong>() <a class="anchor-link" href="#Object"
              title="Permalink to Fixture.Object">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Creates a new <code>Object</code> instance.</p>
<p><code>Object</code> instances have no meaningful state, and are only useful
through their identity. An <code>Object</code> instance is equal to itself
only.</p>
<pre class="source">
const Object();
</pre>
</div>
</div>
<div class="method"><h4 id="synchronize">
<button class="show-code">Code</button>
void <strong>synchronize</strong>(<a href="../box2d_console/BroadPhase.html">BroadPhase</a> broadPhase, <a href="../box2d_console/Transform.html">Transform</a> transformOne, <a href="../box2d_console/Transform.html">Transform</a> transformTwo) <a class="anchor-link" href="#synchronize"
              title="Permalink to Fixture.synchronize">#</a></h4>
<div class="doc">
<pre class="source">
void synchronize(BroadPhase broadPhase, Transform transformOne,
    Transform transformTwo) {
  if (proxy == null) {
    return;
  }

  // Compute an Axis Aligned Box that covers the swept shape.
  shape.computeAxisAlignedBox(_poolOne, transformOne);
  shape.computeAxisAlignedBox(_poolTwo, transformTwo);
  box.lowerBound.x = _poolOne.lowerBound.x &lt; _poolTwo.lowerBound.x ? 
      _poolOne.lowerBound.x : _poolTwo.lowerBound.x;
  box.lowerBound.y = _poolOne.lowerBound.y &lt; _poolTwo.lowerBound.y ?
      _poolOne.lowerBound.y : _poolTwo.lowerBound.y;
  box.upperBound.x = _poolOne.upperBound.x &gt; _poolTwo.upperBound.x ?
      _poolOne.upperBound.x : _poolTwo.upperBound.x;
  box.upperBound.y = _poolOne.upperBound.y &gt; _poolTwo.upperBound.y ?
      _poolOne.upperBound.y : _poolTwo.upperBound.y;

  Vector disp = _poolOne.lowerBound;
  disp.x = transformTwo.position.x - transformOne.position.x;
  disp.y = transformTwo.position.y - transformOne.position.y;

  broadPhase.moveProxy(proxy, box, disp);
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to Fixture.toString">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Returns a string representation of this object.</p>
<pre class="source">
external String toString();
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
